<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="_token" content="{{ csrf_token() }}"/>
    <title>上海宏邦知识产权代理有限公司</title>
    <link rel="Shortcut Icon" href="{{asset('admin_assets/img/HB.ico') }}"/>
    <link rel="Bookmark" href="{{asset('admin_assets/img/HB.ico') }}" />
    <link rel="stylesheet" type="text/css" href="{{asset('admin_assets/css/bootstrap.min.css')}}">
    <link rel="stylesheet" type="text/css" href="{{asset('admin_assets/css/font-awesome/css/font-awesome.min.css')}}">
    <link rel="stylesheet" type="text/css" href="{{asset('admin_assets/css/AdminLTE.min.css')}}">
    <link rel="stylesheet" type="text/css" href="{{asset('admin_assets/css/fileinput.min.css')}}">
    <style>
        html body {
            margin: 0;
            height: 100%;
        }
        .error{
            color: #d91200;
            margin-left: 38%;
            display: none;
        }
        #body {
            width: 100%;
            height: 100%;
            overflow-x: hidden;
            position: relative;
        }

        .clear {
            clear: both
        }

        #header {
            width: 100%;
            height: 60px;
            border-bottom: solid 1px #00a6ff;
            position: fixed;
            top: 0;
        }

        #header-left {
            width: 50%;
            height: 100%;
            min-width: 250px;
            font-size: 20px;
            color: #676767;
            float: left;
        }

        #header-left p {
            margin-top: 16px;
            margin-left: 30px;
        }

        #header-right {
            width: 50%;
            height: 100%;
            min-width: 120px;
            font-size: 20px;
            color: #676767;
            float: right;
        }

        #header-right p {
            font-size: 14px;
            text-align: right;
            margin-right: 10px;
            margin-top: 18px;
            min-width: 125px;
            color: #676767;
        }

        #header-right p a {
            color: #676767;
        }

        #content {
            width: 100%;
            margin-top: 60px;
        }

        #steps {
            height: 48px;
            border-bottom: 2px solid #e6e6e6;
            position: relative;
        }

        #steps ul {
            width: 500px;
            margin: 0 auto;
        }

        .span-title {
            list-style: none;
            width: 150px;
            line-height: 46px;
            text-align: center;
            float: left;
            font-size: 16px;
            color: #999;
        }

        .active {
            border-bottom: solid 2px #0080ff;
        }

        .content-title {
            text-align: center;
            margin-top: 2%;
            font-size: 16px;
            color: #676767;
        }
        .user-type{
            width: 25%;
            margin: 0 auto;
            border-radius: 5px;
            outline: none;
        }
        .user-name{
            width: 25%;
            margin: 0 auto;
            border-radius: 5px;
            outline: none;
        }
        .real-name{
            width: 25%;
            margin: 0 auto;
            border-radius: 5px;
            outline: none;
        }
        .code-num{
            width: 25%;
            margin: 0 auto;
            border-radius: 5px;
            outline: none;
        }
        #btn-confirm {
            width: 25%;
            height: 34px;
            border: none;
            border-radius: 5px;
            background: #0080ff;
            color: white;
            outline: none;
            margin-top: 1%;
            margin-left: 37.5%;
        }
        #footer {
            width: 100%;
            margin-top: 14%;
            position: relative;
            bottom: 0;
            height: 40px;
        }

        #footer_title {
            width: 100%;
            text-align: center;
            bottom: 5px;
            position: relative;
            color: #a8a8a9;
        }
    </style>
</head>
<body>
<div id="body">
    <div id="header">
        <div id="header-left"><p>IP管理系统</p></div>
        <div id="header-right"><p><a href="{{url('/')}}">已有账号,立即登录</a></p></div>
    </div>
    <form action="{{url('user/register/register_password')}}" method="post" enctype="multipart/form-data" onsubmit="return check();">
    {{csrf_field()}}
        <div id="content">
        <div class="row" style="margin-top: 4%">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2">
                <h4 style="font-size: 20px"><i class="fa fa-edit fa-lg" style="color: #0080ff"></i>&nbsp;&nbsp;用户注册</h4>
            </div>
        </div>
        <div class="row" style="margin-top: 1%">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2" id="steps">
                <ul>
                    <li class="span-title"><b>验证手机</b></li>
                    <li class="span-title active"><b>设置账号信息</b></li>
                    <li class="span-title"><b>设置密码</b></li>
                </ul>
            </div>
        </div>
        <div class="row" style="margin-top: 1%">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2">
                <p class="content-title"><b>设置账号信息</b></p>
            </div>
        </div>
        <div class="row" style="margin-top: 1%">
            <input id="hide_tel" name="hide_tel" type="hidden" value="{{$data}}">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2">
                <select class="form-control user-type" id="user_type" name="user_type" onblur="check_type();">
                    <option label="用户类型（个人或企业）" selected="selected"> </option>
                    <option value="0">个人</option>
                    <option value="1">企业</option>
                </select>
                <span id="error_empty_type" class="error"><i class="fa fa-times-circle"></i>请选择用户类型</span>
            </div>
        </div >
        <div class="row" style="margin-top: 1%">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2">
                <input type="text" class="form-control user-name" id="user_name" name="user_name" placeholder="用户名" onblur="check_account();">
                <span id="error_empty_account" class="error"><i class="fa fa-times-circle"></i>请填写用户名</span>
                <span id="error_account" class="error"><i class="fa fa-times-circle"></i>用户名已存在</span>
            </div>
        </div >
            <div class="row" style="margin-top: 1%">
                <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2">
                    <input type="email" class="form-control user-name" id="user_email" name="user_email" placeholder="邮箱" onblur="check_email();">
                    <span id="error_empty_email" class="error"><i class="fa fa-times-circle"></i>请填写邮箱</span>
                    <span id="error_email" class="error"><i class="fa fa-times-circle"></i>邮箱格式错误</span>
                </div>
            </div >
        <div class="row" style="margin-top: 1%">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2">
                <input type="text" class="form-control real-name" id="real_name" name="real_name" placeholder="真实姓名" onblur="check_name();">
                <span id="error_empty_name" class="error"><i class="fa fa-times-circle"></i>请填写真实姓名</span>
            </div>
        </div >
            <div class="row" style="margin-top: 1%">
                <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2">
                    <input type="text" class="form-control real-name" id="company" name="company" placeholder="公司名" onblur="check_company();">
                    <span id="error_empty_company" class="error"><i class="fa fa-times-circle"></i>请填写公司名</span>
                </div>
            </div >
            <div class="row" style="margin-top: 1%">
                <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2">
                    <input type="text" class="form-control real-name" id="address" name="address" placeholder="地址" >
                </div>
            </div >
        <div class="row" style="margin-top: 1%">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2">
                <input type="text" class="form-control code-num" id="code_num" name="code_num" placeholder="证件号（根据用户类型区分）" onblur="check_codenum();">
                <span id="error_empty_code_num" class="error"><i class="fa fa-times-circle"></i>请填写证件号</span>
                <span id="error_code_num" class="error"><i class="fa fa-times-circle"></i>证件号格式错误</span>
            </div>
        </div >
        <div class="row" style="margin-top: 1%">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2">
                <p style="text-align: center;color: #676767;font-size: 18px">上传证件复印件</p>
                <input id="inputFile" type="file" class="file" data-preview-file-type="text" name="file" required>
            </div>
        </div >
        <div class="row" style="margin-top: 1%">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2">
                <button id="btn-confirm">确定</button>
            </div>
        </div >
    </div>
        </form>
    <div id="footer">
        <p id="footer_title">Copyright &copy; 2018 <a style="color: #A8A8A9" href="http://www.hongbung.com" target="_blank">上海宏邦知识产权代理有限公司</a></p>
    </div>
</div>
<script src="{{asset('admin_assets/js/jquery.min.js')}}"></script>
<script src="{{asset('admin_assets/js/fileinput.min.js')}}"></script>
<script src="{{asset('admin_assets/js/fileinput_locale_zh.js')}}"></script>
<script src="{{asset('js/ip.js')}}"></script>
<script>
    $("#inputFile").fileinput({
        language: 'zh',
        autoReplace: false,
        maxFileCount: 1,
        allowedFileExtensions: ["jpg", "png", "gif", "pdf"],
        browseClass: "btn btn-primary",
        showUpload: false,
        showCancel: true,
        previewFileIcon: "<i class='fa fa-upload'></i>"
    });
    $(document).ready(function(){
        $(".file-input-new").css('width','25%');
        $(".file-input-new").css('margin','0 auto');
    });
    function check_type() {
        var type=$("#user_type").val();
        if(type.length==0){
         $(".error").css('display','none');
         $("#error_empty_type").css('display','block');
         $("#btn-confirm").attr('disabled',true);
        }else {
            $(".error").css('display','none');
            $("#btn-confirm").attr('disabled',false);
        }
    }
    function check_email() {
        var email=$("#user_email").val();
        var reg = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/;
        var flag = reg.test(email);
        if(email.length==0){
            $(".error").css('display','none');
            $("#error_empty_email").css('display','block');
            $("#btn-confirm").attr('disabled',true);
        }else if(!flag){
            $(".error").css('display','none');
            $("#error_email").css('display','block');
            $("#btn-confirm").attr('disabled',true);
        }else {
            $(".error").css('display','none');
            $("#btn-confirm").attr('disabled',true);
        }
    }
    function check_account() {
        var account=$("#user_name").val();
        if(account.length==0){
            $(".error").css('display','none');
            $("#error_empty_account").css('display','block');
            $("#btn-confirm").attr('disabled',true);
        }else{
            $.ajax({
                url: "{{url('user/register/ajaxCheckAccount')}}",
                type: 'post',
                dataType: "json",
                headers: {'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')},
                data: {'account': account},
                success: function (data) {
                    if(data==1){
                        $(".error").css('display','none');
                        $("#error_account").css('display','block');
                        $("#btn-confirm").attr('disabled',true);
                    }else{
                        $(".error").css('display','none');
                        $("#btn-confirm").attr('disabled',false);
                    }
                }
            });
        }
    }
    function check_name() {
        var name=$("#real_name").val();
        if(name.length==0){
            $(".error").css('display','none');
            $("#error_empty_name").css('display','block');
            $("#btn-confirm").attr('disabled',true);
        }else{
            $(".error").css('display','none');
            $("#btn-confirm").attr('disabled',false);
        }
    }
    function check_company() {
        var name=$("#company").val();
        if(name.length==0){
            $(".error").css('display','none');
            $("#error_empty_company").css('display','block');
            $("#btn-confirm").attr('disabled',true);
        }else{
            $(".error").css('display','none');
            $("#btn-confirm").attr('disabled',false);
        }
    }
    function check_codenum() {
        var type=$("#user_type").val();
        var codenum=$("#code_num").val();
        if(type.length==0){
            alert('请先选择用户类型');
            $("#btn-confirm").attr('disabled',true);
            return false;
        }
        if(codenum.length==0){
        $(".error").css('display','none');
        $("#error_empty_code_num").css('display','block');
        $("#btn-confirm").attr('disabled',true);
        }else {
            if(type==0){
                var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
                var flag = reg.test(codenum);
                if(!flag){
                    $(".error").css('display','none');
                    $("#error_code_num").css('display','block');
                    $("#btn-confirm").attr('disabled',true);
                }else {
                    $(".error").css('display','none');
                    $("#btn-confirm").attr('disabled',false);
                }
            }
            if(type==1){
                var reg = /^(?:(?![IOZSV])[\dA-Z]){2}\d{6}(?:(?![IOZSV])[\dA-Z]){10}$/;
                var flag = reg.test(codenum);
                if(!flag){
                    $(".error").css('display','none');
                    $("#error_code_num").css('display','block');
                    $("#btn-confirm").attr('disabled',true);
                }else {
                    $(".error").css('display','none');
                    $("#btn-confirm").attr('disabled',false);
                }
            }
        }
    }
    function check() {
        var type=$("#user_type").val();
        var account=$("#user_name").val();
        var name=$("#real_name").val();
        var codenum=$("#code_num").val();
        var file=$("#inputFile").val();
        var email=$("#user_email").val();
        if(type.length==0){
           alert('请选择用户类型');
           return false;
        }else if(account.length==0){
            alert('请填写用户名');
            return false;
        }else if(email.length==0){
            alert('请填写邮箱');
            return false;
        }else if(name.length==0){
            alert('请填写真实姓名');
            return false;
        }else if(codenum.length==0){
            alert('请填写证件号');
            return false;
        }else if(file.length==0){
            alert('请上传证件照');
            return false;
        }else {
            return true;
        }
    }
</script>
</body>
</html>
